﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Text;
using Roy.Data;
using Roy.Entity;
using Roy.Entity.CommonBO;
using Roy.IService;

/*********************************************************
 * 开发人员：鲁宁
 * 创建时间：2015/2/28 16:47:08
 * 描述说明：
 * 
 * 更改历史：
 * 
 * *******************************************************/
namespace Roy.Service
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class RoyMenuService : IRoyMenuService
    {
        /// <summary>
        /// 获取所有菜单【测试左边树形菜单用】
        /// </summary>
        /// <returns></returns>
        public RoyResult<Menu> GetAllMenus()
        {
            var result = new RoyResult<Menu>
            {
                ReturnCode = ReturnCodeType.Error,
                Contents= new List<Menu>()
            };

            Roy.Common.Helper.DBHelper.NoLockInvokeDB(() =>
            {
                using (var db = new RoyDB())
                {
                    result.Contents = db.SM_Menu.ToList();
                    result.ReturnCode = ReturnCodeType.Success;
                }
            });

            return result;
        }
    }
}
